package com.decent.entity.common;


import com.decent.enums.MessageEnum;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;

/**
 * @author decent
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Message implements Serializable {

    private static final long serialVersionUID = -1369948390563179472L;

    /**
     * 状态码
     */
    private Integer errorCode;

    /**
     * 消息内容
     */
    private String errorMsg;

    /**
     * 消息所携带的一组数据
     */
    private Object data;

    public Message(Integer status, String result, Object data) {
        this.errorCode = status;
        this.errorMsg = result;
        this.data = data;
    }

    public Message(Integer status, String result) {
        this.errorCode = status;
        this.errorMsg = result;
    }

    public Message(String result) {
        this.errorMsg = result;
    }

    public Message(Integer status) {
        this.errorCode = status;
    }

    public Message(MessageEnum messageEnum) {
        this.errorCode = messageEnum.getStatus();
        this.errorMsg = messageEnum.getMsg();
    }

    public Message(MessageEnum messageEnum, Object object) {
        this.errorCode = messageEnum.getStatus();
        this.errorMsg = messageEnum.getMsg();
        this.data = object;
    }

    public Message() {

    }

}
